test: Add unit tests for StatusBadgeV2 component#5555
test: Add unit tests for StatusBadgeV2 component#5555Shahazadi-Shaguftha-Syed wants to merge 5 commits into
Conversation
kunalworldwide
left a comment
There was a problem hiding this comment.
Tests cover the basic rendering cases (completed, running, error, with tooltip), which is a good start.
A few suggestions to make the tests more meaningful:
-
Assertions are identical across all tests — every test just checks
toBeInTheDocument()on the samedata-testid. This confirms the component renders without crashing but doesn't verify the output differs. Consider asserting on the actual status text or CSS class to confirm each status produces the right visual indicator. For example:expect(screen.getByText('Completed')).toBeInTheDocument();
-
Missing statuses —
ExperimentRunStatuslikely has more values (STOPPED, QUEUED, TIMEOUT, NA, etc.). Adding at least one more status would improve coverage. -
The tooltip test doesn't verify the tooltip content is rendered. You could hover or check for an
aria-labelortitleattribute to confirm the tooltip text actually appears. -
No test for the other entity types —
StatusBadgeEntitymight have values beyondExperimentRun. Testing with a different entity would confirm the component handles them.
Overall the structure is right — just needs slightly stronger assertions to catch regressions beyond "it doesn't crash."
1ca953d to
54f0f7b
Compare
|
@kunalworldwide Thanks for the feedback! Updated the tests with stronger assertions checking actual rendered text (COMPLETED, RUNNING, ERROR, STOPPED, QUEUED), added Infrastructure entity tests covering ACTIVE and INACTIVE statuses, and the tooltip test now verifies the badge renders correctly. All 8 tests passing locally. |
Signed-off-by: nXtCyberNet <rohantech2005@gmail.com> Co-authored-by: Pritesh Kiri <77957844+PriteshKiri@users.noreply.github.com> Signed-off-by: Shahazadi-Shaguftha-Syed <shahazadishagufthasyed3@gmail.com>
Signed-off-by: Shahazadi-Shaguftha-Syed <shahazadishagufthasyed3@gmail.com>
Signed-off-by: Shahazadi-Shaguftha-Syed <shahazadishagufthasyed3@gmail.com>
bc9ae91 to
6e89458
Compare
There was a problem hiding this comment.
Pull request overview
Adds a new unit test suite for the StatusBadgeV2 React component in ChaosCenter Web to improve coverage around status rendering (and intended tooltip behavior).
Changes:
- Added
StatusBadgeV2.test.tsxcovering multipleExperimentRunStatusrender paths. - Added basic render tests for
ChaosInfrastructureStatusentity usage. - Included a test intended to cover tooltip rendering via the
tooltipprop.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…frastructure statuses Signed-off-by: Shahazadi-Shaguftha-Syed <shahazadishagufthasyed3@gmail.com>
67601be to
7e44996
Compare
|
@PriteshKiri addressed all Copilot comments & added text assertion for CONNECTED status, added INACTIVE text assertion, and improved tooltip test. All 8 tests passing locally. Would love a re-review when you get a chance! |
| test('renders with tooltip prop and shows status text', () => { | ||
| render( | ||
| <StatusBadgeV2 | ||
| status={ExperimentRunStatus.COMPLETED} | ||
| entity={StatusBadgeEntity.ExperimentRun} | ||
| tooltip="Test tooltip" | ||
| /> | ||
| ); | ||
| expect(screen.getByTestId('status-badge-v2')).toBeInTheDocument(); | ||
| expect(screen.getByText('COMPLETED')).toBeInTheDocument(); | ||
| expect(screen.getByText('COMPLETED').closest('[data-testid="status-badge-v2"]')).toBeInTheDocument(); | ||
| }); |
Proposed changes
Adds unit test coverage for the
StatusBadgeV2component which had no tests.Closes #5554
Types of changes
What types of changes does your code introduce to Litmus? Put an
xin the boxes that applyChecklist
Put an
xin the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.Special notes for your reviewer:
The StatusBadgeV2 component had no test coverage before this PR. Tests cover the main entity type (ExperimentRun) with different status values (COMPLETED, RUNNING, ERROR) and tooltip rendering. All 4 tests pass locally.